package com.sskj.givecoin.utils;

/**
 * ProjectName：期权
 * DESC: (类描述)用于将手机号或者邮箱转换为指定格式
 * Created by hqf on 2018/10/22 15:52
 * updateName:(修改人名称)
 * updateTime:(修改时间)
 * updateDesc:(修改内容)
 */
public class StringUtils {
    public static String changeText(String mobile) {
        String start = "";
        String end = "";
        if (CheckUtil.isEmail(mobile)) {
            int i = mobile.indexOf("@");
            if (i == 1 || i == 2) {
                start = mobile.substring(0, 1);
                end = mobile.substring(i, mobile.length());
                return start + "*" + end;
            } else if (i == 3) {
                start = mobile.substring(0, 1);
                end = mobile.substring(i - 1, mobile.length());
                return start + "*" + end;
            } else {
                start = mobile.substring(0, 1);
                end = mobile.substring(i - 2, mobile.length());
                return start + "****" + end;
            }
        } else {
            start = mobile.substring(0, 3);
            end = mobile.substring(7, 11);
            return start + "****" + end;

        }
    }
}
